#ifndef _BSP_PORT_H_
#define _BSP_PORT_H_

#include "main.h"
#include "stdio.h"
#include "string.h"
#include "stdbool.h"

/************************** GPIO *********************************/
#define LED_RUN_OPEN LL_GPIO_SetOutputPin(LED_RUN_GPIO_Port, LED_RUN_Pin)   // 打开运行指示灯
#define LED_RUN_SHUT LL_GPIO_ResetOutputPin(LED_RUN_GPIO_Port, LED_RUN_Pin) // 关闭运行指示灯
#define LED_RUN_TOGG LL_GPIO_TogglePin(LED_RUN_GPIO_Port, LED_RUN_Pin)      // 翻转运行指示灯
#define LED_RUN_ISIN LL_GPIO_IsInputPinSet(LED_RUN_GPIO_Port, LED_RUN_Pin)  // 读取运行指示灯
#define KEY_B1_ISIN LL_GPIO_IsInputPinSet(KEY_B1_GPIO_Port, KEY_B1_Pin)     // 读取拨码开关1
#define KEY_B2_ISIN LL_GPIO_IsInputPinSet(KEY_B2_GPIO_Port, KEY_B2_Pin)     // 读取拨码开关2
#define KEY_B3_ISIN LL_GPIO_IsInputPinSet(KEY_B3_GPIO_Port, KEY_B3_Pin)     // 读取拨码开关3
#define KEY_B4_ISIN LL_GPIO_IsInputPinSet(KEY_B4_GPIO_Port, KEY_B4_Pin)     // 读取拨码开关4

/************************** xxxx *********************************/
typedef enum
{
    BSP_UART1,
    BSP_UART2,
} Bsp_Uart_t;

// 开关类枚举
typedef enum
{
    s_CLOSE, // 关闭
    s_OPEN,  // 打开
} Switch_t;

#define bsp_mDelay(ms) LL_mDelay(ms)
void bsp_Delay_us(uint32_t us);
void bsp_uart_SendData(Bsp_Uart_t Uart, uint8_t *data, uint16_t datalen);

uint64_t get_Timestampus(void);
void TimestampInc(uint32_t Time);

int fputc(int ch, FILE *stream);
void bsp_USART1_SendBytes(uint8_t *Buf, uint8_t length);
void bsp_USART2_SendBytes(uint8_t *Buf, uint8_t length);
void bsp_IWDG_ReloadCounter(void);

void bsp_Ctrl_Water_Valve(Switch_t state);
void bsp_Ctrl_Heat_Switch(Switch_t state);
void bsp_Ctrl_Flowmeter_Switch(Switch_t state);
Switch_t bsp_Get_Water_Valve(void);
Switch_t bsp_Get_Heat_Switch(void);
uint8_t bsp_Get_Kettle_State(void);
uint8_t bsp_Get_Spill_State(void);

#endif

// Kettle 水壶
// Water 水
// heat 加热
// Tim 时间
// Flowmeter 流量计
